home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / cfei.h.z / cfei.h
C/C++ Source or Header  |  1992-04-03  |  11KB  |  376 lines

  1. #ifndef __SYS_CFEI_H__
  2. #define __SYS_CFEI_H__
  3.  
  4. /* @(#) cy.h     Definitions for VME to Low Speed Channel Interface
  5.  *
  6.  ******************************************************************************
  7.  *    The software described herein is public domain and may be used,  
  8.  *    copied, or modified by anyone without restriction.
  9.  ******************************************************************************
  10.  *
  11.  *  h e a d e r  f i l e  f o r   C R A Y  C h a n n e l   D r i v e r
  12.  */
  13. #ident "$Revision: 1.2 $"
  14.  
  15. #define SHIFT 0
  16. #define    AUB_CALL    0x01000000        /* SUN-style buf.h flag */
  17. #define    AUB_COPY    0x02000000        /* copy instead of DMA */
  18. #define    AUB_BLKCOPY    0x04000000        /* copy individual page */
  19. #define    AUB_DISJ    0x08000000        /* use list in djnt array */
  20. #define    AUB_MAPPED    0x10000000        /* IP5 vme mapping done */
  21.  
  22. #define    NDJ    (CYMAX/NBPC + 1)        /* max num of disjoint frags */
  23.  
  24. /*
  25.  * CY constants
  26.  */
  27. #ifndef NCY
  28. #define NCY 4
  29. #endif
  30. #define CY_TIMEOUT    4        /* time out seconds */ 
  31. #define CY_INVDISC    5        /* # of invalid disc intrs allowed */
  32. #define CYMAX        0x40000        /* arbitrary max size transfer (256)*/
  33.  
  34. extern int cfei_cnt;            /* number intfs this machine */
  35.  
  36.  
  37. /*   c y s t a r t    c o m m a n d s   */
  38. #define STC_MCLR 0                /* cystart cmd: master clear */
  39. #define STC_DISC 1                /* cystart cmd: disconnect */
  40. #define STC_READMP 2                /* cystart cmd: read MP */
  41. #define STC_READ 3                /* cystart cmd: read AD */
  42. #define STC_WRITE 4                /* cystart cmd: write */
  43.  
  44.  
  45. /*
  46.  *  c y . f l a g s
  47.  */
  48. #define CY_DISCARD    0x01        /* discarding AD */
  49. #define CY_RBLOCK    0x02        /* block reads because AD present */
  50. #define CY_RAW        0x04        /* this Intf is in raw mode */
  51.  
  52. /*
  53.  *  c y . o p t i o n s
  54.  */
  55. #define    CO_FCOPY    0x08        /* force copying of data */
  56. #define    CO_FDISJ    0x10        /* force no joining in disjointio */
  57.  
  58. /*
  59.  *  c y . s t a t e
  60.  */
  61. #define    FS_RESET    0        /* reset  */
  62. #define FS_READ     1        /* read in progress */
  63. #define FS_WRITE    2        /* write in progress */
  64. #define FS_RDWR        3        /* read and write in progress */
  65.  
  66. /*
  67.  * data structures
  68.  */
  69. struct djntio {
  70.     paddr_t    addr;
  71.     int    count;
  72. };
  73.  
  74. /* cyio structs are used by cysetup to return (addr,len) pair */
  75. struct cyio {
  76.     char *addr;
  77.     int len;
  78. };
  79.  
  80. #ifdef IP5
  81. struct cymap {
  82.     dmamap_t    *cm_dmamap;    /* vme map, 24 bits on clover 2 */
  83.     caddr_t        cm_start;    /* start of mapped area */
  84.     int        cm_fudge;    /* fudge + start --> dma_addr */
  85. };
  86. #define    PAGE_BASE_ADDR(x) ((caddr_t)((int)x & -NBPP))
  87. #endif
  88.  
  89. /* cybufs are used to describe a user's IO request */
  90. struct cybuf {
  91.     struct buf buf;            /* MUST BE FIRST */
  92.     /*
  93.      *    Augmented buffer variables.
  94.      */
  95.     int    (*aub_iodone)();    /* call on completion if non-zero */
  96.     struct    cy_msg    *aub_mp_ptr;    /* user's virt I/O buf pointer for mp */
  97.     caddr_t    aub_ad_ptr;        /* user's virt pointer for assoc data */
  98.     int    aub_flags;        /* extended flags */
  99.     struct    cympbuf    *aub_mp;    /* points to associated cympbuf */
  100.     struct    djntio    *aub_djp;    /* point to entry in dj */
  101.     struct    djntio    dj[NDJ];
  102.     struct    cyio    aub_bpt;    /* describe each block in transit */
  103. };
  104.  
  105. #define    EBP    ((struct cybuf *) bp)    /* get at extended portion of buf */
  106.  
  107. /* cympbuf's are used to store out-going and in-coming message propers */
  108.  
  109. struct cympbuf {
  110.     struct cympbuf    *m_forw;
  111.     time_t        m_late;
  112.     paddr_t    m_vaddr;        /* DVMA addr of m_msg */
  113.     struct cy_msg    m_msg;
  114. };
  115.  
  116. #define CYMPNUM    30        /* number of cympbuf's */
  117. #define CYBNUM    20        /* number of bufs in pool */
  118. #define b_cympbuf av_back    /* pointer to message proper */
  119.  
  120. #define    KBUFSZ    65536
  121.  
  122. #ifdef KERNEL
  123.  
  124. /* cy_ch keeps information on a per logical channel basis */
  125.  
  126. struct cy_ch    {                /* logical channel struct */
  127.     int        open;        /* channel open flag */
  128.     int        header;        /* user wants message propers */
  129.     int        raw;        /* this channel using raw mode */
  130.     struct buf    *rf;        /* first buf on read queue */
  131.     struct buf    *rl;        /* last buf on read queue  */
  132.     struct cympbuf    *mf;        /* first incoming msg */
  133.     struct cympbuf    *ml;        /* last  incoming msg */
  134.     int        nmsg;        /* number of msg's on queue */
  135.     int        mquota;        /* msg quota exceeded */
  136.     int        mnooc;        /* message, no open channel */
  137.     int        mtout;        /* message proper timeout */
  138.     struct    pollqueue inpq;        /* select system call - input */
  139.     struct    pollqueue excq;        /* select system call - exceptions */
  140. };
  141.  
  142. /* cy_info keeps information on a per interface basis */
  143.  
  144. struct cy_info {            /* 1 per cy interface */
  145.     int        flags;        /* status bits */
  146.     int        cy_options;    /* functionality controlling flags */
  147.     int        cy_buflimit;    /* artificially restrict bcopy size */
  148.     int        state;        /* current state  */
  149.     int        open;        /* number of open CY channels */
  150.     /*int        last;        /* last opened CY channel */
  151.     short        intf;        /* Number of this intf, shifted << 2 */
  152.                     /* to match usage of minor device no */
  153.     short        board;        /* board set number */
  154.     int        invdisc;    /* number of invalid disc intrs */
  155.     int        discsecs;    /* seconds to timeout on disconnect */
  156.     time_t        rlate;        /* read time out time/date */
  157.     time_t        wlate;        /* write time out time/date */
  158.     /*struct mb_device *md;        /* pointer to mb_device struct */
  159.     struct cv_device *cvp;        /* pointer to memory mapped HW */
  160.     struct buf    *wf;        /* first buf on write queue */
  161.     struct buf    *wl;        /* last buf on write queue */
  162.     struct buf    *bpr;        /* current read buffer  */
  163.     struct buf    *bpw;        /* current write buffer */
  164.     struct cympbuf    *mp;        /* buffer for "msg proper" */
  165.  
  166.     struct    cystats    cy_stat;    /* statistics */
  167.  
  168.     struct cv_stat    cv_stat;    /* contents of write only regs */
  169.     struct cy_ch    cy_ch[NCHAN];    /* 1 per logical channel */
  170.  
  171. #ifdef IP5
  172.     struct cymap    cy_ivmemap;
  173.     struct cymap    cy_ovmemap;
  174. #endif /* IP5 */
  175.     char    rdbuffer[KBUFSZ];    /* place to read all physio data */
  176.     char    wrbuffer[KBUFSZ];    /* place to write all physio data */
  177.     int        cy_wlen;    /* length of last write */
  178.     int        cy_rlen;    /* length of last issued read */
  179.  
  180.     struct    cybuf    cy_discbuf;    /* buf descrip. for discard */
  181.     struct    cybuf    cy_rb;        /* buf descrip. for read mp */
  182.     struct    cybuf    cy_wb;        /* buf descrip. for write mp */
  183.  
  184.     struct    pollqueue outq;        /* select system call - output */
  185. };
  186.  
  187. #endif
  188.  
  189. /*          C Y   M a c r o s             */
  190.  
  191. /*
  192.  *    These macros work on the minor device number or the interrupt
  193.  *    vector number.
  194.  *        ii.. ....    interface number of minor number 
  195.  *        ..ll llll    logical channel of minor number
  196.  *        .... xx..    interface number of interrupt vector
  197.  *        .... ..vv    vector of interrupt vector
  198.  *
  199.  * CY(X) gets the interface number of X, shifted right
  200.  * VEC(X) gets the interface number of X, shifted right
  201.  * CYCH(X) gets the logical channel of X
  202.  */
  203. #define CY(X)    ( ((int) (X) >> 6) & 03 )    /* minor -> interface */
  204. #define CYCH(X)    ( (int) (X) & 0x3F )         /* logical channel */
  205. #define VEC(X)    ( ((int) (X) >> 2) & 03 )    /* vector -> interface */
  206.  
  207. /*
  208.  * For low level debugging, there is a wrap around trace buffer
  209.  * with UTSIZE/4 time-stamped entries.
  210.  */
  211.  
  212. #define    UTSIZE    8192
  213. struct    cytraceb {
  214.     int    cytb_size;
  215.     int    *cytb_ptr;
  216.     struct    cytraceb *cytb_me;
  217.     int    cytb_buf[UTSIZE];
  218. };
  219.  
  220. #ifdef    DEBUG
  221.  
  222. extern    struct    cytraceb    cytracebuf;
  223.  
  224. #define    UTINIT()                    \
  225.     {                        \
  226.     cytracebuf.cytb_ptr = cytracebuf.cytb_buf;    \
  227.     cytracebuf.cytb_size = UTSIZE;            \
  228.     cytracebuf.cytb_me = &cytracebuf;        \
  229.     }
  230.  
  231. #ifdef UTPRINT
  232. #define    UTRACE(M,X,Y)                    \
  233.     printf ("%d %x %x %x\n", (int)(time), (int)(M), (int)(X), (int)(Y));
  234. #else
  235. #define    UTRACE(M,X,Y)                    \
  236.     {                         \
  237.     *cytracebuf.cytb_ptr++ = (int)(time);        \
  238.     *cytracebuf.cytb_ptr++ = (int)(M);        \
  239.     *cytracebuf.cytb_ptr++ = (int)(X);        \
  240.     *cytracebuf.cytb_ptr++ = (int)(Y);        \
  241.     if (cytracebuf.cytb_ptr >= &cytracebuf.cytb_buf[UTSIZE])    \
  242.         cytracebuf.cytb_ptr = cytracebuf.cytb_buf;        \
  243.     }
  244. #endif
  245.  
  246. #define UTDUMP()                    \
  247.     {                        \
  248.     register int *p;                \
  249.     printf ("\n");                    \
  250.     for (p=cytracebuf.cytb_buf; p<&cytracebuf.cytb_buf[UTSIZE]; p += 4) \
  251.         printf ("%x %x %x %x\n", *p, *(p+1), *(p+2), *(p+3));    \
  252.     printf ("\n");                    \
  253.     }
  254.  
  255. /* Values for M */
  256. #define UTR_CLOSE    0x01
  257. #define UTR_SREAD    0x02        /* strategy routine read */
  258. #define UTR_SWRITE    0x03        /* strategy routine write */
  259. #define UTR_IOCTL    0x04
  260. #define UTR_START    0x05
  261. #define UTR_IDISC    0x06
  262. #define UTR_IDMA1    0x07
  263. #define UTR_IWRITE    0x08
  264. #define UTR_TACTIVERD    0x09
  265. #define UTR_TMP        0x0a
  266. #define UTR_TSIG    0x0b
  267. #define UTR_DISCARD    0x0c        /* discard-AD routine called */
  268. #define UTR_CLEAR    0x0d
  269. #define UTR_FSMERR    0x0e
  270. #define UTR_READ    0x0f
  271. #define UTR_WRITE    0x10
  272. #define UTR_STRAT    0x11
  273. #define UTR_IDMP    0x12
  274. #define UTR_FSMNULL    0x13
  275. #define UTR_INTR    0x14
  276. #define UTR_APPEND    0x15
  277. #define UTR_READMP    0x16
  278. #define UTR_IMCLR    0x17
  279. #define UTR_SETUP    0x18
  280. #define UTR_OPEN    0x19
  281. #define    UTR_IWRITE1    0x1a
  282. #define    UTR_IWRITE2    0x1b
  283. #define UTR_STRATEXIT    0x1c
  284. #define UTR_STRATDISJ    0x1d
  285. #define UTR_SETUPDISJ    0x1e
  286. #define UTR_INTREND    0x1f
  287. #define UTR_STARTADDR    0x20
  288. #define UTR_IDISC_MP    0x21
  289. #define UTR_STRATFLGS    0x22
  290. #define UTR_CLOSESTAT    0x23
  291. #define UTR_SETUPVIR    0x24
  292. #define    UTR_IWRITEFUDGE    0x25
  293. #define    UTR_SWRITEFUDGE    0x26
  294. #define    UTR_DISCARDFUDGE 0x27
  295. #define    UTR_READMPFUDGE    0x28
  296. #define    UTR_MAPALLOC    0x29
  297. #define    UTR_MAP        0x2a
  298. #define    UTR_SETUPPHYS    0x2b
  299. #define    UTR_OPENPHYS    0x2c
  300. #define    UTR_STARTMAPRG    0x2d
  301. #define    UTR_DISJCOPY    0x2e
  302. #define    UTR_LISTSTRAT    0x2f
  303. #define    UTR_DISCMPERR    0x30
  304. #define    UTR_DISJLIST    0x31
  305. #define    UTR_MPDUMP    0x32
  306. #define    UTR_MPDUMPADR    0x33
  307. #define    UTR_TDISC    0x34
  308. #define    UTR_STARTDONE    0x35
  309. #define UTR_TACTIVEWR    0x36
  310. #define UTR_ICONDSCMCL    0x37
  311. #define UTR_ICONRDWR    0x38
  312. #define UTR_BAD_INTERRUPT 0x39
  313. #define UTR_TACTRESID    0x3a
  314. #define UTR_LSTRATEXIT    0x3b
  315. #define UTR_NOMPBUFS    0x3c
  316. #define UTR_IDISCLOOP    0x3d
  317. #define UTR_TSIGRWRESID    0x3e
  318. #define UTR_TSIGSTAT    0x3f
  319. #define UTR_STARTICON    0x40
  320. #define UTR_EDTINITDN    0x41
  321. #define UTR_READMP_MP    0x42
  322. #define UTR_POLL    0x43
  323. #define UTR_OCANCELWR    0x44
  324. #define    UTR_OCANRESID    0x45
  325. #define UTR_TACTIVE    0x46
  326. #define    UTR_IF_INPEIO    0x47
  327. #define    UTR_IDISC2    0x48
  328. #define    UTR_IDISCEIO    0x49
  329.  
  330.  
  331. /* Values for M for if_cray.c */
  332. #define UTR_IF_ATTACH    0x80
  333. #define    UTR_IF_RESET    0x81
  334. #define    UTR_IF_INIT    0x82
  335. #define    UTR_IF_OUTPUT    0x83
  336. #define    UTR_IF_START    0x84
  337. #define    UTR_IF_IOCTL    0x85
  338. #define    UTR_IF_INTRI    0x86
  339. #define    UTR_IF_FLGCNT    0x87
  340. #define    UTR_IF_DESTCNT    0x88
  341. #define    UTR_IF_NONIPPKT    0x89
  342. #define    UTR_IF_NOMBUFS    0x8a
  343. #define    UTR_IF_UNUSED    0x8b
  344. #define    UTR_IF_INTRO    0x8c
  345. #define    UTR_IF_INTRO1    0x8d
  346. #define    UTR_IF_INPCHAIN    0x8e
  347. #define    UTR_IF_EXTRACT    0x8f
  348. #define    UTR_IF_STRTOLST    0x90
  349. #define    UTR_IF_STRTOHDR    0x91
  350. #define    UTR_IF_CHKSUMLN    0x92
  351. #define    UTR_IF_HSHROUTE    0x93
  352. #define    UTR_IF_NONROUTE    0x94
  353. #define    UTR_IF_BADROUTE    0x95
  354. #define    UTR_IF_LOOPBACK    0x96
  355. #define    UTR_IF_OUTLOOP    0x97
  356. #define    UTR_IF_DROP    0x98
  357. #define    UTR_IF_RTEMTU    0x99
  358. #define    UTR_IF_STRTOMLEN 0x9a
  359. #define UTR_IF_EDTINIT    0x9b
  360.  
  361. #else
  362. #define    UTINIT()
  363. #define    UTRACE(M,X,Y)
  364. #define    UTDUMP()
  365. #endif
  366.  
  367. /* Values for X and Y depend on M */
  368.  
  369.  
  370. /* til gets defined somewhere: */
  371. #define    IFF_ALIVE        (IFF_UP|IFF_RUNNING)
  372. #define    iff_alive(flags)    (((flags) & IFF_ALIVE) == IFF_ALIVE)
  373. #define iff_dead(flags)        (((flags) & IFF_ALIVE) != IFF_ALIVE)
  374.  
  375. #endif /* __SYS_CFEI_H__ */
  376.